package com.hrt.manage.sms.modual.service.impl;

import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hrt.bean.Role;
import com.hrt.bean.SMSModual;
import com.hrt.manage.sms.modual.dao.SMSModualDao;
import com.hrt.manage.sms.modual.service.SMSModualService;

@Service
public class SMSModualServiceImpl implements SMSModualService{

	@Autowired
	private SMSModualDao dao;
	
	@Override
	public List<SMSModual> listModuals() {
		// TODO Auto-generated method stub
		List<SMSModual> list=new ArrayList<SMSModual>();
		list=dao.listModuals();
		return list;
	}

	@Override
	public List<SMSModual> queryByPage(int pageIndex, int pageSize) {
		
		List<SMSModual> list = new ArrayList<SMSModual>();
		list = dao.queryByPage(pageIndex, pageSize);

		return list;
	}

	@Override
	public Long totalCount() {
		// TODO Auto-generated method stub
		return dao.totalCount();
	}

	@Override
	public List<SMSModual> queryByPage(List<Map<String, Object>> conditions,
			Integer pageIndex, Integer pageSize) {
		// TODO Auto-generated method stub
				List<SMSModual> results = new ArrayList<SMSModual>();
				results = dao.queryByPage(conditions,pageIndex, pageSize);
				return results;
	}

	@Override
	public Timestamp getDate() {
		// TODO Auto-generated method stub
		return dao.getDate();
	}

	@Transactional
	@Override
	public Long saveModual(SMSModual modual) {
		// TODO Auto-generated method stub
		return dao.saveEntity(modual);
	}

	@Transactional
	@Override
	public Long[] deleteById(Long[] idArr) {
		List<Long> delArr = new ArrayList<Long>();
		if (idArr != null && idArr.length > 0) {
			for (Long id : idArr) {
				SMSModual c = dao.getById(id);
				c.setIsdelete(new Integer(1));
				dao.updateEntity(c);
				delArr.add(id);
			}
		}
		return delArr.toArray(new Long[delArr.size()]);
		
	}

	
	@Override
	public SMSModual getModualById(Long moId) {
		// TODO Auto-generated method stub
		SMSModual  modual=dao.getModualById(moId);
		return modual;
	}

	@Transactional
	@Override
	public void updateModual(SMSModual oldModual) {
		// TODO Auto-generated method stub
		 dao.updateEntity(oldModual);
	}

	
	/**
	 * 根据业务类型代码获取短信模版数据
	 * @param businessCode
	 * @see com.hrt.thirtyparty.sms.SMSBusinessType
	 * @return
	 */
	@Override
	public SMSModual getModualByBusinessCode(Integer businessCode) {
		// TODO Auto-generated method stub
		SMSModual  modual=dao.getModualByBusinessCode(businessCode);
		return modual;
		
	}

}
